<?php
/**
 * 编辑岗位
 * @author ray
 */
apf_require_controller("HrAbstract");

class Hr_Ajax_UpdateJobController extends HrAbstractController {

    public function handle_request() {
        $params = $this->request->get_parameters();

        $status=0;
        //检测参数合法性
        $this->_check_params($params);

        $job_bll = new Bll_Hr_Job();
        $result = $job_bll->update_plan_by_id($params['jobID'], $params['formation']);
        if($result !== false){
            $status = 1;
            $this->json_encode($status,$result);
        }else{
            $this->json_encode($status,Const_Tip::ERROR_JOB_DB);
        }

    }
    /**
     * 参数检测
     */
    private function _check_params($params){
        $status = 0;
        $params['formation'] = intval($params['formation']);
        if(empty($params['jobID'])){
            $this->json_encode($status,Const_Tip::ERROR_PARAM);
        }
        if($params['formation'] < 0 || $params['formation'] > 1000){
            $this->json_encode($status,Const_Tip::ERROR_JOB_PLAN_LENGTH);
        }
    }
}